<!--新版导入组件示例（未使用）-->
<template>
    <div>
        <Row type="flex" justify="start">
            <Col span="3">
                <Button type="default" long @click="backAction">返回</Button>
            </Col>
        </Row>
        <wl-excel-import
                :interface-url="interfaceUrl"
                :template-url="templateUrl"
                :uni-key="uniKey"
                :validate-data="validateData"
                :handle-data="handleData"
                :fail-column="failColumn"
        ></wl-excel-import>
    </div>
</template>

<script>
import excelTemplate from '@/libs/excel-template.js'
// import { validateAllList } from '@/libs/excel-validate.js'
// import { handleAllList } from '@/libs/excel-handle.js'

export default {
  data () {
    return {
      // 传入类型（用于判断处理）
      excelType: '',
      // 导入接口url
      interfaceUrl: '',
      // 导入模板地址
      templateUrl: '',
      // 预前校验数据重复的key
      uniKey: 'card_no',
      // 格式校验方法
      validateData: () => {},
      // 数据处理方法
      handleData: () => {},
      // 失败数据的列头
      failColumn: [
        {
          key: 'name',
          title: '姓名'
        },
        {
          key: 'card_no',
          title: '身份证号'
        }
      ]
    }
  },
  beforeMount () {},
  methods: {
    init () {
      this.excelType = this.$route.query && this.$route.query.type
      switch (this.excelType) {
        case 'all':
          this.interfaceUrl = ''
          this.templateUrl = excelTemplate.all
          // this.validateData = validateAllList
          // this.handleData = handleAllList
          break
      }
    },
    backAction () {
      switch (this.excelType) {
        case 'all':
          this.$router.push({ name: 'recordList' })
          break
        default:
          this.$router.push({ name: 'index' })
          break
      }
    }
  },
  mounted () {
    this.init()
  }
}
</script>

<style scoped>
</style>
